package com.zhang.boot.web.controller;

import com.zhang.boot.core.service.UserService;
import com.zhang.boot.core.vo.Result;
import com.zhang.boot.core.vo.router.RouterVo;
import com.zhang.boot.core.vo.user.UserInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author zhangshaobin
 * @Date 2020/10/22
 * @Description 用户相关接口
 */
@Api(tags = "用户api")
@RestController
@RequestMapping("/api/user")
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;

    @ApiOperation("获取用户信息")
    @GetMapping("/info")
    public Result info() {
        UserInfoVo userInfoVo = userService.getUserInfo();
        return Result.ok(userInfoVo);
    }

    /**
     * TODO 该接口暂时返回空数组
     * @return
     */

    @ApiOperation("获取用户路由菜单")
    @GetMapping("/getRouters")
    public Result getRouters() {
        List<RouterVo> routers = userService.getRouters();
        return Result.ok(routers);
    }



    @ApiOperation("删除用户")
    @PostMapping("/delete/{username}")
    @PreAuthorize("@ss.hasPermission('system:user:delete')")
    public Result delete(@PathVariable String username) {
        return Result.ok();
    }


}
